package www.icomwell.com.viperdemo.Modules.List.UserInterface.View;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ListView;

import java.util.List;

import www.icomwell.com.viperdemo.Modules.List.UserInterface.Presenter.DisplayData;
import www.icomwell.com.viperdemo.Modules.List.UserInterface.Presenter.ListPresenter;
import www.icomwell.com.viperdemo.R;

/**
 * Created by leeesven on 17/5/22.
 */

public class ListActivity extends Activity implements ListViewInterface{

	private ListView mToDoList;
	private ListAdapter mListAdapter;

	private ListPresenter mListPresenter;

	@Override
	protected void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list);

		mToDoList = (ListView) findViewById(android.R.id.list);
		mListAdapter = new ListAdapter();
		mToDoList.setAdapter(mListAdapter);

		mListPresenter = new ListPresenter(this);
	}

	@Override
	protected void onResume() {
		super.onResume();

		mListPresenter.updateView();
	}

	@Override
	public void showUpcomingDisplayData(List<DisplayData> displayDatas) {
		mListAdapter.setDisplayDataList(displayDatas);
		mListAdapter.notifyDataSetChanged();
	}
}
